<?php
/**
 *
 *
 */
class Yz_Model_Field_Checkbox
    extends Yz_Model_Field_Abstract
{
    // unchecked by default
    const DEFAULTVALUE = false;



    /** Initialization value
     *  @return
     */
    public function assignValue($value)
    {
        if (null === $value)
            return $this->getDefaultValue();
        return Yz_String::isTrue($value);
    }


    /** Test if a value is a valid true/false
     *  @param mixed value
     *  @return bool
     *  @throw TypeError
     */
    protected function _testValue($value)
    {
        $value = Yz_String::isTrue($value);
        if (null === $value)
            throw TypeError::_new_();
        return $value;
    }

}
